package vcp.application;

/*
 *  Application initializes MVC architecture
 */

import vcp.controllers.LoginController;
import vcp.controllers.MainController;
import vcp.controllers.OrdersGuestController;
import vcp.gui.forms.CancelOrderForm;
import vcp.gui.forms.OrderOccasionalForm;
import vcp.gui.forms.OrderSubscriptionForm;
import vcp.gui.forms.OrderTemporaryForm;
import vcp.gui.forms.OrderTrackForm;
import vcp.models.LoginModel;
import vcp.models.MainModel;
import vcp.models.OrdersCancelOrderModel;
import vcp.models.OrdersModel;
import vcp.models.OrdersOccasionalOrderModel;
import vcp.models.OrdersSubscriptionModel;
import vcp.models.OrdersTemporaryModel;
import vcp.models.OrdersTrackModel;
import vcp.views.LoginView;
import vcp.views.MainView;
import vcp.views.OrderGuestView;


public class Application extends Bootstrapper {
	private MainModel mainModel;
	private MainView mainView;
	private MainController mainController;
	
	private OrdersModel ordersGuestModel;
	private OrderGuestView ordersGuestview;
	private OrdersGuestController ordersGuestController;
	private OrdersCancelOrderModel ordersCancelOrderModel;
	private OrdersOccasionalOrderModel ordersOccasionalOrderModel;
	private OrdersSubscriptionModel ordersSubscriptionModel;
	private OrdersTemporaryModel ordersTemporaryModel;
	private OrdersTrackModel ordersTrackModel;
	private LoginView loginView;
	private LoginModel loginModel;
	private LoginController loginController;
	

	
	public Application() {
		initApplication();
	}
	private void initApplication() {		   	 
		    mainModel = new MainModel();
			mainView = new MainView();
			mainController = new MainController();
			
			/* order guests instance */
			ordersGuestModel = new OrdersModel();
			ordersCancelOrderModel = new OrdersCancelOrderModel();
			ordersOccasionalOrderModel = new OrdersOccasionalOrderModel();
			ordersSubscriptionModel = new OrdersSubscriptionModel();
			ordersTemporaryModel = new OrdersTemporaryModel();
			ordersTrackModel = new OrdersTrackModel();
			
			ordersGuestview = new OrderGuestView();
			ordersGuestController = new OrdersGuestController();
			
			
			loginView = new LoginView();
			loginModel = new LoginModel();
			loginController = new LoginController();
			
			
			ordersOccasionalOrderModel.addObserver(ordersGuestview.getOrderOccasionalViewForm());
			ordersSubscriptionModel.addObserver(ordersGuestview.getOrderSubscriptionForm());
			ordersTemporaryModel.addObserver(ordersGuestview.getOrderTemporaryViewForm());
			ordersCancelOrderModel.addObserver(ordersGuestview.getCancelOrderViewForm());
			ordersTrackModel.addObserver(ordersGuestview.getOrderTrackViewForm());
			
			ordersGuestController.addModel("ordersGuestModel",ordersGuestModel);
			ordersGuestController.addModel("ordersCancelOrderModel",ordersCancelOrderModel);
			ordersGuestController.addModel("ordersOccasionalOrderModel",ordersOccasionalOrderModel);
			ordersGuestController.addModel("ordersSubscriptionModel",ordersSubscriptionModel);
			ordersGuestController.addModel("ordersTemporaryModel",ordersTemporaryModel);
			ordersGuestController.addModel("ordersCancelOrderModel",ordersCancelOrderModel);
			ordersGuestController.addModel("ordersTrackModel",ordersTrackModel);
			ordersGuestController.addView(ordersGuestview);
			ordersGuestview.addController(ordersGuestController);
			
			loginModel.addObserver(loginView);
			loginController.addModel(loginModel);
			loginController.addView(loginController);
			loginView.addController(loginController);
			
			/* main application instance */
			mainModel.addObserver(mainView);			
			mainController.addModel(mainModel);
			mainController.addView(mainView);
			mainView.addController(mainController);
			
			mainView.registerView("OrdersGuestView",ordersGuestview);
			mainView.registerView("LoginView",loginView);

	}
	
	
}
